<template>
    <div style="margin-bottom: 50px;">
        <div class="content" v-if="parentCode"><span class="subTile"></span>{{parentCode}} {{parentDesc}}</div>
        <el-table
            :data="recordData"
            :span-method="objectSpanMethod"
            border
            :cell-style="tableCellStyle"
            :header-cell-style="tableHeaderCellStyle"
            style="width: 100%; margin-top: 20px;border:1px solid black;">
            <el-table-column
                prop="name"
                label="指标名称">
            </el-table-column>
            <el-table-column
                prop="lever"
                label="能力等级">
            </el-table-column>
        </el-table>
        <div class="title">能力等级：{{options.eva.expertEvalScore}}</div>
        <div class="content"><span class="subTile">评估结果：</span>{{options.eva.evaluationDtlBiz.expertEvalResult}}</div>
        <div class="content"><span class="subTile">不足：</span>{{options.eva.expertEvalLack}}</div>
        <div class="content"><span class="subTile">建议：</span>{{options.eva.expertEvalBiz}}</div>
    </div>
</template>

<script>
export default {
    props: {
        options : {
            type : Object,
            default: (() => {
                return {}
            })
        }
    },
    data(){
        return {
            recordData : [],
            parentCode : "",
            parentDesc : "",
        }
    },
    async mounted () {
        let parentTarget = await this.getParentTarget();
        console.log('🚀 ~ parentTarget', parentTarget);
        let parent = parentTarget.filter((item) => {
            return item.indexId === this.options.base.biz2
        })
        if(parent.length > 0){
            this.parentCode = parent[0].indexCode;
            this.parentDesc = parent[0].indexDesc;
        }
        this.options.base.anIndexAbilityOptionsList = this.options.base.anIndexAbilityOptionsList.sort(wfy.sortBy('status'))
        // console.log('🚀 ~ this.options.base.anIndexAbilityOptionsList', this.options.base)
        this.options.base.anIndexAbilityOptionsList.forEach((item) => {
            this.recordData.push({
                name: this.options.base.indexCode + " " + this.options.base.indexDesc,
                lever: item.status + "、" + item.optionsDesc
            })
        })
    },
    methods: {
        // 修改 table cell边框的背景色，行高，字体大小
        tableCellStyle() {
            return 'border-color: black; font-size:20px;height:50px'
        },
        // 修改 table header cell的背景色，行高，字体大小
        tableHeaderCellStyle() {
            return 'border-color: black; color: black; background:#FFFFFF;font-size:20px;height:50px'
        },
        objectSpanMethod({ row, column, rowIndex, columnIndex }) {
            if (columnIndex === 0) {
                if (rowIndex % 5 === 0) {
                    return {
                        rowspan: 5,
                        colspan: 1
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0
                    };
                }
            }
        },
        getParentTarget(){
            return new Promise((resolve, reject) => {
                this.$http({
                    url: this.$http.adornUrl(`/admin/basIndex/listall`),
                    method: 'get',
                    params: this.$http.adornParams({
                        "biz1": "1"
                    })
                }).then(({ data }) => {
                    console.log('🚀 ~ data', data)
                    resolve(data);
                })
            })
        },
    }
}
</script>

<style lang="scss" scoped>
.title{
    font-size: 20px;
    font-weight: bold;
    line-height: 80px;
}
.subTile{
    font-size: 20px;
    font-weight: bold;
}
.content{
    font-size: 20px;
    line-height: 30px;
    margin-bottom: 20px;
}
</style>
